package com.taowan.xunbaozl.morning_speak.design_pattern.day12;

/**
 * Created by wgl on 2016/3/7.
 */
public class MyBuilder {
    public static void main(String[] args){
        Director director = new Director();
        Product product1 = director.getAproduct();
        product1.showProduct();

        Product product2 = director.getBProduct();
        product2.showProduct();
    }
}

class Product{
    private String name;
    private String type;
    public void showProduct(){

    }

    public void setName(String name) {
        this.name = name;
    }

    public void setType(String type) {
        this.type = type;
    }
}

abstract class Builder{
    public abstract void setPart(String arg1,String arg2);
    public abstract Product getProduct();
}

class ConcreteBuilder extends Builder{
    private Product product = new Product();
    @Override
    public void setPart(String arg1, String arg2) {
        product.setName(arg1);
        product.setType(arg2);
    }

    @Override
    public Product getProduct() {
        return product;
    }
}

class Director{
    private Builder builder=new ConcreteBuilder();

    public Product getAproduct(){
        builder.setPart("宝马汽车","X7");
        return builder.getProduct();
    }
    public Product getBProduct(){
        builder.setPart("奥迪汽车","Q5");
        return builder.getProduct();
    }
}